package array

/*
desc: 接雨滴
url: https://leetcode.com/problems/container-with-most-water/
 */

func maxArea(list []int) int {
	var (
		start = 0
		end = len(list) - 1
		//i = 0
		maxVal = 0
	)
	for {
		if start >= end {
			break
		}
		if list[start] >= list[end] {
			maxVal = max((end-start)*list[end], maxVal)
			end--
		} else {
			maxVal = max((end-start)*list[start], maxVal)
			start++
		}
	}

	return maxVal
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}
